# class Dog(object):
#     tooth = 10
#
#
# wangcai = Dog()
# xiaohei = Dog()
#
# # 1. 类 类.类属性 = 值
# # Dog.tooth = 20
# # print(Dog.tooth) #20
# # print(wangcai.tooth) #20
# # print(xiaohei.tooth) #20
#
#
# # 2. 测试通过对象修改类属性
# wangcai.tooth = 200
#
# print(Dog.tooth)  # 10
# print(wangcai.tooth)  # 200
# print(xiaohei.tooth)  # 10


class Dog(object):
    def __init__(self):
        self.age = 5

    def info_print(self):
        print(self.age)


wangcai = Dog()
print(wangcai.age)  # 5
"""
Traceback (most recent call last):
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\文件资料\python-study\Code\07-面向对象\03-面向对象其他\hm_03_修改类属性.py", line 33, in <module>
    print(Dog.age)  # 报错：实例属性不能通过类访问
          ^^^^^^^
AttributeError: type object 'Dog' has no attribute 'age'
"""
print(Dog.age)  # 报错：实例属性不能通过类访问
wangcai.info_print()  # 5